package com.goldgov.information.service.impl;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.goldgov.information.dao.ArticleDao;
import com.goldgov.information.service.Article;
import com.goldgov.information.service.ArticleQuery;
import com.goldgov.information.service.ArticleService;
import com.goldgov.utils.DateUtil;
import com.goldgov.utils.PropertyUtil;
@Service
public class ArticleServiceImpl implements ArticleService {

	@Autowired
	ArticleDao articleDao;
	
	@Override
	public List<Article> getArticleList(ArticleQuery query) {
		return articleDao.getArticleList(query);
	}

	@Override
	public void updateArticle(Article article) {
		articleDao.updateArticle(article);
	}

	@Override
	public void addArticle(Article article) {
		if (PropertyUtil.objectNotEmpty(article.getPublishDateText())) {
			article.setPublishDate(DateUtil.getTime(article.getPublishDateText()));
		}
		articleDao.addArticle(article);
	}

	@Override
	public Article getArticleByID(String articleID) {
		return articleDao.getArticleByID(articleID);
	}

	@Override
	public int existArticleByUrl(String url) {
		return articleDao.existArticleByUrl(url);
	}

	@Override
	public void deleteArticleByIDs(String[] ids) {
		articleDao.deleteArticleByIDs(ids);
	}

	@Override
	public void cancelArticles(String[] ids) {
		articleDao.cancelArticles(ids);
	}

	@Override
	public void deleteArticlesByRulesID(String id) {
		articleDao.deleteArticlesByRulesID(id);
	}
	/**
	 * 获取未审核数据
	 * @date 2018年9月11日 下午2:48:41 
	 * @author hanxiangyu
	 * @param ids
	 * @return
	 */
	public int findNoAudit(String[] ids) {
		return articleDao.findNoAudit(ids);
	}
	
	/**
	 * 获取已发布的数据
	 * @param ids
	 * @return
	 */
	public int findPublish(String[] ids) {
		return articleDao.findPublish(ids);
	}
	
}
